package com.ldq.imooc.basics.dataOperation;

import java.sql.SQLException;
import java.util.*;

/**
 * @Author : 李道泉
 * @Description :
 * @Date : 2018/4/27 9:32
 * @Modified by :
 */
public class GoddessAction {

    public Goddess get(Integer id) throws SQLException {
        GoddessDao dao = new GoddessDao();
        return dao.querySingle(id);
    }

    public void add(Goddess goddess) throws SQLException {
        GoddessDao dao = new GoddessDao();
        dao.addGoddess(goddess);
    }

    public void edit(Goddess goddess) throws SQLException {
        GoddessDao dao = new GoddessDao();
        dao.updateGoddess(goddess);
    }

    public void del(Integer id) throws SQLException {
        GoddessDao dao = new GoddessDao();
        dao.deleteGoddess(id);
    }

    public List<Goddess> query() throws SQLException {
        GoddessDao dao = new GoddessDao();
        return dao.goddessList();
    }

    public List<Goddess> query(List<Map<String, Object>> params) throws SQLException {
        GoddessDao dao = new GoddessDao();
        return dao.query(params);
    }

//    public static void main(String[] args) throws SQLException {
//
//        GoddessDao goddessDao = new GoddessDao();
////        Goddess goddess1 = new Goddess();
////        goddess1.setUser_name("赫本");
////        goddess1.setSex(2);
////        goddess1.setAge(24);
////        goddess1.setBirthday(new Date());
////        goddess1.setEmail("ldq0730@foxmail.com");
////        goddess1.setMobile("18888888888");
////
////        goddess1.setUpdate_user("administrator");
////        goddess1.setIsdel(1);
//
////        goddess1.setCreate_user("administrator");
////        goddessDao.addGoddess(goddess1);
////        goddessDao.deleteGoddess(7);
//
////        goddess1.setId(8);
////        goddessDao.updateGoddess(goddess1);
//
////        Goddess god = goddessDao.querySingle(9);
////        System.out.println(god.toString());
////        System.out.println();
//
//        List<Map<String, Object>> params = new ArrayList<>();
//        Map<String, Object> param = new HashMap<>();
//        param.put("name", "user_name");
//        param.put("rela", "=");
//        param.put("value", "'赫本'");
//
//        params.add(param);
//
//        List<Goddess> result = goddessDao.query(params);
//        for (int i = 0; i < result.size(); i++) {
//            System.out.println(result.get(i).toString());
//        }
//    }
}
